home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Bus / S / Stock HELPER®.cpt / Stock HELPERÆ V0.2 / stack.txt < prev   
Text File  |  1988-03-23  |  9KB  |  283 lines

  1. -- stack: in.2
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x0 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 4
  11. -- first background id: 19480
  12. -- card count: 8
  13. -- first card id: 36467
  14. -- list block id: 2952
  15. -- print block id: 17075
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 41440 bytes
  21. -- stack block size: 8192 bytes
  22. -- created by hypercard version: 0x00000000
  23. -- compacted by hypercard version: 0x00000000
  24. -- modified by hypercard version: 0x00000000
  25. -- opened by hypercard version: 0x00000000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. on openStack
  69.   Global operationMode,dateforUpdate
  70.   global UpdateField,span1,span2,span3
  71.   global upArrow,downArrow
  72.   global maxDataPoints,minBaseValue
  73.   global firstChart,saveLevel
  74.   hide message box
  75.   hide menubar
  76.   put the userLevel into saveLevel
  77.   set userLevel to 3
  78.   put 16692 into upArrow
  79.   put 3584 into downArrow
  80.   put 5 into span1
  81.   put 15 into span2
  82.   put 40 into span3
  83.   put 52 into maxDataPoints
  84.   put 10000 into minBaseValue
  85.   put 7 into firstChart -- number of first chart card
  86. end openStack
  87.  
  88. on closeStack
  89.   global saveLevel
  90.   set userLevel to saveLevel
  91. end closeStack
  92.  
  93. on clearScreen
  94.   choose select tool
  95.   doMenu select all
  96.   doMenu clear picture
  97. end clearScreen
  98.  
  99. function maxLine what,itemNr
  100. put item itemNr of line 1 of what into result
  101. repeat with i = 2 to the number of lines in what
  102.   put max(result,item itemNr of line i of what) into result
  103. end repeat
  104. return result
  105. end maxLine
  106.  
  107. function minLine what,itemNr
  108. put item itemNr of line 1 of what into result
  109. repeat with i = 2 to the number of lines in what
  110.   put min(result,item itemNr of line i of what) into result
  111. end repeat
  112. return result
  113. end minLine
  114.  
  115. function rounders sum,span
  116. put round(100*(sum/span))/100 into result
  117. return result
  118. end rounders
  119.  
  120. on ScrolltoLastLine
  121.   global operationMode,dateforUpdate,lineCount
  122.   if operationMode="Update" then
  123.     if dateforUpdate‚â†item 1 of line lineCount of field "data" then
  124.       get line lineCount of field "data"
  125.       put it&return&dateforUpdate into line lineCount of field "data"
  126.       add 1 to lineCount
  127.       get line lineCount of field "data"
  128.       put it&"," into line lineCount of field "data"
  129.       put lineCount-4 into scrolledLines
  130.       if scrolledLines>0 then
  131.         multiply scrolledLines by the textheight of field "Data"
  132.         set the scroll of field "Data" to scrolledLines
  133.       end if
  134.     end if
  135.   end if
  136. end ScrolltoLastLine
  137.  
  138. on arrowDirection arrowNr
  139.   put "bkgnd button ""e&"Direction "&arrowNr"e into direction
  140.   get line arrowNr of field "Directions"
  141.   if it>0 then
  142.     set the icon of direction to it
  143.     show direction
  144.   else
  145.     hide direction
  146.   end if
  147. end arrowDirection
  148.  
  149. on MovingAverage Avg,avgNr,span,itemNr
  150.   global lineCount
  151.   global upArrow,downArrow
  152.   put 0 into avga
  153.   put 0 into avgb
  154.   put lineCount into itemCount
  155.   put "Average "&avgNr into avgField
  156.   if lineCount>=span then
  157.     put rounders(Avg,span) into field avgField
  158.   else
  159.     put empty into field avgField
  160.   end if
  161.   if lineCount>=span+2 then
  162.     if itemNr>0 then
  163.       put item itemNr of line itemCount of field "data" into endValue1
  164.       subtract 1 from itemCount
  165.       put item itemNr of line itemCount of field "data" into endValue2
  166.       subtract span-1 from itemCount
  167.       put item itemNr of line itemCount of field "data" into pastValue1
  168.       subtract 1 from itemCount
  169.       put item itemNr of line itemCount of field "data" into pastValue2
  170.     else
  171.       put -itemNr into lowItem
  172.       put lowItem-1 into highItem
  173.       put item highItem of line itemCount of field "data" into endValue1
  174.       subtract item lowItem of line itemCount of field "data" from endValue1
  175.       subtract 1 from itemCount
  176.       put item highItem of line itemCount of field "data" into endValue2
  177.       subtract item lowItem of line itemCount of field "data" from endValue2
  178.       subtract span-1 from itemCount
  179.       put item highItem of line itemCount of field "data" into pastValue1
  180.       subtract item lowItem of line itemCount of field "data" from pastValue1
  181.       subtract 1 from itemCount
  182.       put item highItem of line itemCount of field "data" into pastValue2
  183.       subtract item lowItem of line itemCount of field "data" from pastValue2
  184.     end if
  185.     put Avg into Avga
  186.     subtract endValue1 from Avga
  187.     add pastValue1 to Avga
  188.     put Avga into Avgb
  189.     subtract endValue2 from Avgb
  190.     add pastValue2 to Avgb
  191.     put 0 into iconNr
  192.     if Avg > Avga then
  193.       if Avga>Avgb then
  194.         put upArrow into iconNr
  195.       end if
  196.     else
  197.       if Avg < Avga then
  198.         if Avga < Avgb then
  199.           put downArrow into iconNr
  200.         end if
  201.       end if
  202.     end if
  203.   else
  204.     put 0 into iconNr
  205.   end if
  206.   put iconNr into line avgNr of field "Directions"
  207.   arrowDirection avgNr
  208. end MovingAverage
  209.  
  210. on ClearFields
  211.   put empty into field "Date of Last Update"
  212.   put empty into field "high"
  213.   put empty into field "low"
  214.   put empty into field "close"
  215.   put empty into field "Average 1"
  216.   put empty into field "Average 2"
  217.   put empty into field "Average 3"
  218.   put the number of lines of field "data" into lineCount
  219.   repeat with i=1 to 3
  220.     put 0 into line i of field "Directions"
  221.     arrowDirection i
  222.   end repeat
  223. end ClearFields
  224.  
  225. on TrimDataPoints  -- Reduce data points to maxDataPoints
  226.   global maxDataPoints,lineCount
  227.   repeat while last line of field "data" is empty
  228.     delete last line of field "data"
  229.   end repeat
  230.   repeat while number of lines of field "data" > maxDataPoints
  231.     delete line 1 of field "data"
  232.   end repeat
  233.   put the number of lines of field "data" into lineCount
  234. end TrimDataPoints
  235.  
  236. on SetforUpdate
  237.   global operationMode,dateforUpdate,lineCount
  238.   if operationMode="Update" then
  239.     if dateforUpdate‚â†item 1 of line lineCount of field "data" then
  240.       get line lineCount of field "data"
  241.       put it&return&dateforUpdate into line lineCount of field "data"
  242.       add 1 to lineCount
  243.       get line lineCount of field "data"
  244.       put it&"," into line lineCount of field "data"
  245.       put lineCount-4 into scrolledLines
  246.       if scrolledLines>0 then
  247.         multiply scrolledLines by the textheight of field "Data"
  248.         set the scroll of field "Data" to scrolledLines
  249.       end if
  250.     end if
  251.   else
  252.     put number of lines of field "data" into lineCount
  253.     if lineCount>1 then
  254.       scrolltoLastLine
  255.     end if
  256.   end if
  257. end SetforUpdate
  258.  
  259. on QuickUpdate
  260.   global dateforUpdate,lineCount,cardNr,updateFlag
  261.   -- Assumes at card cardNr
  262.   put "skip" into updateFlag
  263.   put field "Stock Symbol" into StockSymbol
  264.   put field "Stock Name" into StockName
  265.   put the number of lines of field "data" into lineCount
  266.   get line lineCount of field "data"
  267.   if dateforUpdate‚â†item 1 of it then
  268.     go card "Update All"
  269.     set lockScreen to false
  270.     put StockSymbol into field "Symbol"
  271.     put StockName into field "Name"
  272.     put item 1 of it into field "Last Week"
  273.     delete item 1 of it
  274.     put it into field "Last Week's Prices"
  275.     put dateforUpdate into field "This Week"
  276.     put empty into field "This Week's Prices"
  277.     set lockScreen to true
  278.   else
  279.     add 1 to cardNr
  280.   end if
  281. end QuickUpdate
  282.  
  283.